package org.weasel.wizards;

import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.wizard.Wizard;
import org.weasel.business.Developer;
import org.weasel.business.Settings;

public class CreateDeveloperWizard extends Wizard{
	private CreateDeveloperWizardPage1 wizardPage1;
	private ISelection selection;
	private Settings setts;

	public CreateDeveloperWizard(String settingsPath) throws Exception {
		super();
		setts = new Settings(settingsPath);
		setWindowTitle("Add a new developer to "+settingsPath);
		setNeedsProgressMonitor(true);
	}
	
	@Override
	public void addPages() {
        wizardPage1 = new CreateDeveloperWizardPage1(selection);
        addPage(wizardPage1);
    }

	@Override
	public boolean performFinish() {
		String id = wizardPage1.getDeveloperID();
		String name = wizardPage1.getDeveloperName();
		String mail = wizardPage1.getDeveloperMail();
		String position = wizardPage1.getDeveloperPosition();
		Developer d = new Developer(id, name, mail, position);
		try {
			setts.addDeveloper(d);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return true;
	}
}
